package com.example._06springaop.aop;

import org.springframework.stereotype.Component;

@Component
public class CalculatorImp implements Calculator{
    @Override
    public int add(int a, int b) {
        if(a>0){
            throw new RuntimeException("a的值必须大于0");
        }
        int result=a+b;
        System.out.println("方法内部add:"+result);
        return result;
    }

    @Override
    public int sub(int a, int b) {
        int result=a-b;
        System.out.println("方法内部sub:"+result);
        return result;
    }

    @Override
    public int mul(int a, int b) {
        int result=a*b;
        System.out.println("方法内部mul:"+result);
        return result;
    }

    @Override
    public int div(int a, int b) {
        int result = a / b;
        System.out.println("方法内部div:"+result);
        return result;
    }
}
